package com.action;

import org.apache.struts2.ServletActionContext;

import com.bean.Student;
import com.bean.Teacher;
import com.dao.StudentDao;
import com.dao.TeacherDao;
import com.opensymphony.xwork2.ActionSupport;
import com.util.HttpUtil;

public class FinduserinfoAction extends ActionSupport{
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private int stuUserID;
	private int teaUserID;
	private int type;
	
	public int getStuUserID() {
		return stuUserID;
	}
	
	public void setStuUserID(int stuUserID) {
		this.stuUserID = stuUserID;
	}

	public int getType() {
		return type;
	}
	
	public void setType(int type) {
		this.type = type;
	}

	public void setTeaUserID(int teaUserID) {
		this.teaUserID = teaUserID;
	}

	public int getTeaUserID() {
		return teaUserID;
	}
	


	//学生教师查找个人信息表
	public String finduserinfo()throws Exception {
		if(this.type == 1){
		StudentDao dao = new StudentDao();
		Student stu = (Student) ServletActionContext.getRequest().getSession().getAttribute("stu");
		int stuid = stu.getStuUserID();
		stu = dao.findStuInfo(stuid);		
		HttpUtil.setSession("stu", stu);
		return SUCCESS;
		}else if(this.type == 2){
			System.out.println("2222");
			TeacherDao dao = new TeacherDao();
			Teacher tea = (Teacher) ServletActionContext.getRequest().getSession().getAttribute("tea");
			int teaid = tea.getTeaUserID();
			tea = dao.findTeaInfo(teaid);		
			HttpUtil.setSession("tea", tea);
			return SUCCESS;
		}
		return null;
		
	}



}
